package com.iot08.api.service;

import com.iot08.common.entity.app.OperateLog;
import com.iot08.common.service.base.BaseAdminService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author cwj
 * @description
 * @date 2025/2/22 15:35
 **/
@Slf4j
@Service
public class OperateLogService extends BaseAdminService<OperateLog> {

    /**
     * @description 保存操作日志
     * @author cwj
     * @param [openid, name, imei, opreateName, opreateStatus, param, methodNamme, desc]
     * @return void
     * @date @time 2025/2/22 15:43
     **/
    public void saveOperateLog(String openid,String name,String imei, String opreateName,Integer opreateStatus,String param,String methodNamme,String desc){
        OperateLog operateLog = new OperateLog();
        if(StringUtils.isNotEmpty(openid)){
            operateLog.setOpenid(openid);
        }
        if(StringUtils.isNotEmpty(name)){
            operateLog.setName(name);
        }
        if(StringUtils.isNotEmpty(imei)){
            operateLog.setImei(imei);
        }
        operateLog.setOpreateName(opreateName);
        operateLog.setOpreateStatus(opreateStatus);
        if(StringUtils.isNotEmpty(param)){
            operateLog.setParam(param);
        }
        operateLog.setMethodName(methodNamme);
        operateLog.setDesc(desc);
        operateLog.setCreateTime(new Date());
        this.save(operateLog);
    }
}
